/*
 * Copyright (c) 2011 Anthony Vandikas
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation 
 * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, 
 * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software 
 * is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#include "stdafx.h"
#include "Student.h"

Student::Student() { }

Student::Student(const QString &name, const QString &identifier, const QString &password)
	: name(name), identifier(identifier), password(password)
{ }

QString Student::getName() const { return name; }
QString Student::getIdentifier() const { return identifier; }
QString Student::getPassword() const { return password; }

void Student::setName(const QString &value) { name = value; }
void Student::setIdentifier(const QString &value) { identifier = value; }
void Student::setPassword(const QString &value) { password = value; }

// It's best for the teacher to see both name and student number
// (especially in the case of duplicate first and last names).
QString Student::toString() const { return name + " (" + identifier + ")"; }

bool Student::operator ==(const Student &other) const
{
	return name == other.name && identifier == other.identifier && password == other.password;
}

bool Student::operator !=(const Student &other) const
{
	return !(*this == other);
}

QDataStream &operator <<(QDataStream &stream, const Student &value)
{
	return stream << value.getName() << value.getIdentifier() << value.getPassword();
}

QDataStream &operator >>(QDataStream &stream, Student &value)
{
	QString name, identifier, password;
	stream >> name >> identifier >> password;

	value.setName(name);
	value.setIdentifier(identifier);
	value.setPassword(password);

	return stream;
}
